package cn.bgs.service.impl;

import cn.bgs.mapper.AnnouncementsMapper;
import cn.bgs.page.PageRequest;
import cn.bgs.pojo.Announcement;
import cn.bgs.service.AnnouncementsService;
import cn.bgs.utils.R;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class AnnouncementsServiceImpl implements AnnouncementsService {
    @Autowired
    private AnnouncementsMapper announcementsMapper;
    @Override
    public PageInfo<Announcement> announcementSelect(PageRequest pageRequest,String theTheme) {
        PageHelper.startPage(pageRequest.getPageNum(),pageRequest.getPageSize());
        PageInfo<Announcement> userPageInfo = new PageInfo<>(announcementsMapper.selectAll(theTheme));
        return userPageInfo;
    }

    @Override
    public R announcementAdd(Announcement announcement) {
        int i = announcementsMapper.announcementAdd(announcement);
        return R.ok().data("i",i);
    }

    @Override
    public R announcementUpdate(Announcement announcement) {
        int i = announcementsMapper.announcementUpdate(announcement);
        return R.ok().data("i",i);
    }

    @Override
    public R announcementDelect(Integer announcementId) {
        int i = announcementsMapper.announcementDelect(announcementId);
        return R.ok().data("i",i);
    }
}
